home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _CHGATTR.C < prev    next >
Text File  |  1992-11-21  |  2KB  |  69 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3.  
  4. #ifndef        NDEBUG
  5. char *rcsid__chgattr = "$Header: c:/curses/private/RCS/_chgattr.c%v 2.0 1992/11/15 03:24:20 MH Rel $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_chg_attrs()      - Change attributes in a rectangle
  14.  
  15.   PDCurses Description:
  16.        This routine will change the attribute(s) from a starting (y,x)
  17.        position to an ending (y,x) position to the specified attribute.
  18.  
  19.   PDCurses Return Value:
  20.        This function returns OK on success and ERR on error.
  21.  
  22.   PDCurses Errors:
  23.        It is an error to call this function with a NULL window pointer.
  24.        It is also an error to pass rectangular coordinates that lay
  25.        outside of window.
  26.  
  27.   Portability:
  28.        PDCurses        int PDC_chg_attrs( WINDOW* w, chtype attr,
  29.                                        int sy, int sx,
  30.                                        int ey, int ex );
  31.  
  32. **man-end**********************************************************************/
  33.  
  34. int    PDC_chg_attrs(WINDOW *w, chtype attr, int sy, int sx, int ey, int ex)
  35. {
  36.        chtype  oldattr = w->_attrs;
  37.        int     c;
  38.        int     l;
  39.  
  40.        if (w == (WINDOW *)NULL)                return( ERR );
  41.        if (sy > w->_maxy)      return( ERR );
  42.        if (sx > w->_maxx)      return( ERR );
  43.        if (ey >= w->_maxy)     ey = w->_maxy - 1;
  44.        if (ex >= w->_maxx)     ex = w->_maxx - 1;
  45.  
  46.        wattrset(w, attr);
  47.        for (l = sy; l <= ey; l++)
  48.        {
  49.                for (c = sx; c <= ex; c++)
  50.                        w->_y[l][c] = (w->_y[l][c] & A_CHARTEXT) | attr;
  51.  
  52.                if (w->_firstch[l] == _NO_CHANGE)
  53.                {
  54.                        w->_firstch[l] = sx;
  55.                        w->_lastch[l] = ex;
  56.                }
  57.                else
  58.                if (w->_firstch[l] != _NO_CHANGE)
  59.                {
  60.                        if (sx < w->_firstch[l])
  61.                                w->_firstch[l] = sx;
  62.                        if (ex > w->_lastch[l])
  63.                                w->_lastch[l] = ex;
  64.                }
  65.        }
  66.        w->_attrs = oldattr;
  67.        return( OK );
  68. }
  69.